import request from '@/utils/request'

// 查询vorder列表
export function listOrder(query) {
  return request({
    url: '/vanger/order/list',
    method: 'get',
    params: query
  })
}

//列表
// export function orderListRequest(data) {
//   return request({
//     url: '/vanger/order/api/list',
//     method: 'post',
//     data: data
//   })
// }

export function orderListRequest(query) {
  return request({
    url: '/vanger/order/api/list',
    method: 'get',
    params: query
  })
}

// 详情
export function getOrderDetail(query) {
  return request({
    url: '/vanger/order/api/info',
    method: 'get',
    params: query
  })
}

// 订单指派x
export function assignOrderRequest(data) {
  return request({
    url: '/vanger/order/api/allot',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 抢单审核x
export function checkOrderRequest(data) {
  return request({
    url: '/vanger/order/api/lootAudit',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 订单取消x
export function cancelOrderRequest(data) {
  return request({
    url: '/vanger/order/api/cancel',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 立即出发x
export function setOutRequest(data) {
  return request({
    url: '/vanger/order/api/depart',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 上门签到x
export function reachRequest(data) {
  return request({
    url: '/vanger/order/api/signIn',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 撤销订单x
export function revokeOrderRequest(data) {
  return request({
    url: '/vanger/order/api/repeal',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 调整金额x
export function adjustAmountRequest(data) {
  return request({
    url: '/vanger/order/api/adjustAmount',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 挂单x
export function holdOrderRequest(data) {
  return request({
    url: '/vanger/order/api/pauseOrder',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 线下支付审核x
export function payCheckRequest(data) {
  return request({
    url: '/vanger/order/api/offlinePayAudit',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 服务分析-诊断x
export function serviceAnalysisRequest(data) {
  return request({
    url: '/vanger/order/api/diagnosis',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  })
}

// 开始服务
export function startServeRequest(data) {
  return request({
    url: '/vanger/order/api/startServer',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 继续服务x
export function continueServiceRequest(data) {
  return request({
    url: '/vanger/order/api/continueOrder',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 服务完成x
export function endServiceRequest(data) {
  return request({
    url: '/vanger/order/api/finish',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  })
}

// 分配佣金x
export function allocationMoneyRequest(data) {
  return request({
    url: '/vanger/order/api/allotCommission',
    method: 'post',
    data: data,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
      }
      return ret;
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 服务类型
export function getOrderShowStatus() {
  return request({
    url: '/vanger/common/api/getOrderShowStatus',
    method: 'get'
  })
}

// 配件类型
export function getPartTypes() {
  return request({
    url: '/vanger/common/api/getPartTypes',
    method: 'get',
  })
}

// 配件库
export function getParts(query) {
  return request({
    url: '/vanger/common/api/getParts/' + query,
    method: 'get',
  })
}

//申请配件
export function applyPartRequest(data) {
  return request({
    url: '/vanger/order/api/applyParts',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  })
}


// 查询vorder列表（联合）
export function listUnion(query) {
  return request({
    url: '/vanger/order/listUnion',
    method: 'get',
    params: query
  })
}


// 查询vorder详细（联合）
export function getInfoUnion(id) {
  return request({
    url: '/vanger/order/getInfoUnion/' + id,
    method: 'get'
  })
}

// 查询vorder详细
export function getOrder(id) {
  return request({
    url: '/vanger/order/' + id,
    method: 'get'
  })
}

// 新增vorder
export function addOrder(data) {
  return request({
    url: '/vanger/order',
    method: 'post',
    data: data
  })
}

// 修改vorder
export function updateOrder(data) {
  return request({
    url: '/vanger/order',
    method: 'put',
    data: data
  })
}

// 删除vorder
export function delOrder(id) {
  return request({
    url: '/vanger/order/' + id,
    method: 'delete'
  })
}
